package org.sdp.pearproject.controller;


import org.sdp.pearproject.controller.custom.*;
import org.sdp.pearproject.dto.request.*;
import org.sdp.pearproject.dto.response.*;

import java.util.List;

import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

/**
 * @ClassName: ProjectAuthController
 * @Description:
 * @Author: SDP
 * @Date: 2022-07-20
 * @Version: 1.0
 * Table: pear_project_auth
 * Comment:
 * 项目权限表
 */
@RestController
@RequestMapping(value = "/project_auth")
public class ProjectAuthController extends ProjectAuthCustomController {
    static {
        addRequestClass("project_auth", "add", "projectAuthController", ProjectAuthController.class, ProjectAuthAddRequest.class);
        addRequestClass("project_auth", "add_encrypt", "projectAuthController", ProjectAuthController.class, ProjectAuthAddRequest.class);

        addRequestClass("project_auth", "update", "projectAuthController", ProjectAuthController.class, ProjectAuthUpdateRequest.class);
        addRequestClass("project_auth", "update_encrypt", "projectAuthController", ProjectAuthController.class, ProjectAuthUpdateRequest.class);

        addRequestClass("project_auth", "delete", "projectAuthController", ProjectAuthController.class, ProjectAuthDeleteRequest.class);
        addRequestClass("project_auth", "delete_encrypt", "projectAuthController", ProjectAuthController.class, ProjectAuthDeleteRequest.class);

        addRequestClass("project_auth", "query", "projectAuthController", ProjectAuthController.class, ProjectAuthQueryRequest.class);
        addRequestClass("project_auth", "query_encrypt", "projectAuthController", ProjectAuthController.class, ProjectAuthQueryRequest.class);

        addRequestClass("project_auth", "list", "projectAuthController", ProjectAuthController.class, ProjectAuthQueryRequest.class);
        addRequestClass("project_auth", "list_encrypt", "projectAuthController", ProjectAuthController.class, ProjectAuthQueryRequest.class);

        addRequestClass("project_auth", "count", "projectAuthController", ProjectAuthController.class, ProjectAuthQueryRequest.class);
        addRequestClass("project_auth", "count_encrypt", "projectAuthController", ProjectAuthController.class, ProjectAuthQueryRequest.class);

        addRequestClass("project_auth", "stat", "projectAuthController", ProjectAuthController.class, ProjectAuthQueryRequest.class);
        addRequestClass("project_auth", "stat_encrypt", "projectAuthController", ProjectAuthController.class, ProjectAuthQueryRequest.class);

    }

    @PostMapping("/add")
    public Integer addProjectAuth(@MixRequestBody ProjectAuthAddRequest request, Integer callFromEncrypt) throws Exception {
        super.fixRequest("project_auth", "add", request, callFromEncrypt);
        return super.addProjectAuth(request);
    }

    @PostMapping("/add_encrypt")
    public String addProjectAuthEncrypt(@MixRequestBody String strRequest) throws Exception {
        ProjectAuthAddRequest request = (ProjectAuthAddRequest) super.decrypt("project_auth", "add_encrypt", strRequest, ProjectAuthAddRequest.class);
        Integer result = addProjectAuth(request, 1);
        if (result == null) {
            return null;
        }
        String response = toJSONString(result);

        return super.encrypt(request, response);
    }

    @PostMapping("/update")
    public Integer updateProjectAuth(@MixRequestBody ProjectAuthUpdateRequest request, Integer callFromEncrypt) throws Exception {
        super.fixRequest("project_auth", "update", request, callFromEncrypt);
        return super.updateProjectAuth(request);
    }

    @PostMapping("/update_encrypt")
    public String updateProjectAuthEncrypt(@MixRequestBody String strRequest) throws Exception {
        ProjectAuthUpdateRequest request = (ProjectAuthUpdateRequest) super.decrypt("project_auth", "update_encrypt", strRequest, ProjectAuthUpdateRequest.class);
        Integer result = updateProjectAuth(request, 1);
        if (result == null) {
            return null;
        }
        String response = toJSONString(result);

        return super.encrypt(request, response);
    }

    @PostMapping("/delete")
    public Integer deleteProjectAuth(@MixRequestBody ProjectAuthDeleteRequest request, Integer callFromEncrypt) throws Exception {
        super.fixRequest("project_auth", "delete", request, callFromEncrypt);
        return super.deleteProjectAuth(request);
    }

    @PostMapping("/delete_encrypt")
    public String deleteProjectAuthEncrypt(@MixRequestBody String strRequest) throws Exception {
        ProjectAuthDeleteRequest request = (ProjectAuthDeleteRequest) super.decrypt("project_auth", "delete_encrypt", strRequest, ProjectAuthDeleteRequest.class);
        Integer result = deleteProjectAuth(request, 1);
        if (result == null) {
            return null;
        }
        String response = toJSONString(result);

        return super.encrypt(request, response);
    }

    @PostMapping("/query")
    public ProjectAuthQueryResponse queryProjectAuth(@MixRequestBody ProjectAuthQueryRequest request, Integer callFromEncrypt) throws Exception {
      super.fixRequest("project_auth", "query", request, callFromEncrypt);
      return super.queryProjectAuth(request);
    }

    @PostMapping("/query_encrypt")
    public String queryProjectAuthEncrypt(@MixRequestBody String strRequest) throws Exception {
        ProjectAuthQueryRequest request = (ProjectAuthQueryRequest) super.decrypt("project_auth", "query_encrypt", strRequest, ProjectAuthQueryRequest.class);
        ProjectAuthQueryResponse result = queryProjectAuth(request, 1);
        if (result == null) {
            return null;
        }
        String response = toJSONString(result);

        return super.encrypt(request, response);
    }

    @PostMapping("/list")
    public List<ProjectAuthQueryResponse> listProjectAuth(@MixRequestBody ProjectAuthQueryRequest request, Integer callFromEncrypt) throws Exception {
        super.fixRequest("project_auth", "list", request, callFromEncrypt);
        if (super.needTotal("project_auth", "list", request)) {
            super.setTotal("project_auth", "list", request, super.countProjectAuth(request));
        }
        return super.listProjectAuth(request);
    }

    @PostMapping("/list_encrypt")
    public String listProjectAuthEncrypt(@MixRequestBody String strRequest) throws Exception {
        ProjectAuthQueryRequest request = (ProjectAuthQueryRequest) super.decrypt("project_auth", "list_encrypt", strRequest, ProjectAuthQueryRequest.class);
        List<ProjectAuthQueryResponse> result = listProjectAuth(request, 1);
        if (result == null) {
            return null;
        }
        String response = toJSONString(result);

        return super.encrypt(request, response);
    }

    @PostMapping("/count")
    public Integer countProjectAuth(@MixRequestBody ProjectAuthQueryRequest request, Integer callFromEncrypt) throws Exception {
      super.fixRequest("project_auth", "count", request, callFromEncrypt);
      return super.countProjectAuth(request);
    }


    @PostMapping("/count_encrypt")
    public String countProjectAuthEncrypt(@MixRequestBody String strRequest) throws Exception {
        ProjectAuthQueryRequest request = (ProjectAuthQueryRequest) super.decrypt("project_auth", "count_encrypt", strRequest, ProjectAuthQueryRequest.class);
        Integer result = countProjectAuth(request, 1);
        if (result == null) {
            return null;
        }
        String response = toJSONString(result);

        return super.encrypt(request, response);
    }

    @PostMapping("/stat")
    public BaseStatResponse statProjectAuth(@MixRequestBody ProjectAuthQueryRequest request, Integer callFromEncrypt) throws Exception {
        super.fixRequest("project_auth", "stat", request, callFromEncrypt);
        return super.statProjectAuth(request);
    }

    @PostMapping("/stat_encrypt")
    public String statProjectAuthEncrypt(@MixRequestBody String strRequest) throws Exception {
        ProjectAuthQueryRequest request = (ProjectAuthQueryRequest) super.decrypt("project_auth", "stat_encrypt", strRequest, ProjectAuthQueryRequest.class);
        BaseStatResponse result = statProjectAuth(request, 1);
        if (result == null) {
            return null;
        }
        String response = toJSONString(result);

        return super.encrypt(request, response);
    }


}
